<?php
namespace app\goods\validate;
use think\Validate;
class Goods extends Validate {
    //验证字段
    protected $rule = [
        'name' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'name.require' => '商品名字必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['name']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['name','id']);
    }
}
